{% extends "base.html" %}
{% load i18n %}

{% block title %} {% trans "My folders" %} - Mr. Edu {%endblock%}

{% block section%}

	<h1>
		{% trans "My folders" %}
		{% if collections %}
		<form class="toolbar{% if userRole == 'teacher' %} rightLeft{% endif %}" id="filter" action="/mrEdu/{{userRole}}/collections/" method="post">
			<label class="toolbar">{% trans "[LABEL] Order by" %}:
				<select id="filterType" name="filter" onchange="return applyFilter()">
					{% if formData == 'recent' %}
					<option value="recent" selected="selected">{% trans "[FILTER] Most recent" %}</option>
					{% else %}
					<option value="recent">{% trans "[FILTER] Most recent" %}</option>
					{% endif %}
					
					{% if formData == 'oldest' %}
					<option value="oldest" selected="selected">{% trans "[FILTER] Oldest" %}</option>
					{% else %}
					<option value="oldest">{% trans "[FILTER] Oldest" %}</option>
					{% endif %}
				</select>
			</label>
			{% csrf_token %}
		</form>
		{% endif %}
		{% if userRole == 'teacher' %}
		<span class="button right"><a href="/mrEdu/{{userRole}}/class/choose">{% trans "[BUTTON] New folder" %}</a></span>
		{% endif %}
	</h1>
	
	<div id="collectionList">
		{% if feedback%}
			<div id="feedback">
				{% for item in feedback %}
					{{item|safe}}
				{% endfor %}
			</div>
		{% endif %}
		{% if collections %}
		<ul class="collectionL">
			{% for collection in collections %}
			<li>
				<a href="/mrEdu/{{userRole}}/collection/{{collection.id}}/">
					{% if collection.name|length > 12 %}
					{% for l in collection.name|make_list|slice:":12" %}{{l}}{% endfor %} ...
					{% else %}
					{{collection.name}}
					{% endif%}
					<span class="hidden">{% trans "Created" %}:</span>
					<span class="creationDate">{{collection.creation_date|date:"d M Y"}}</span>
				</a>
			</li>
			{% endfor %}
		</ul>
		{% else %}
			{% if userRole == 'teacher' %}
		<div id="feedback"><p class="message">{% trans "[MESSAGE] You didn't create any folder yet." %} <a href="/mrEdu/{{userRole}}/class/choose">{% trans "[MESSAGE] Create a folder" %}</a> {% trans "[MESSAGE] and enjoy!" %}</p></div>
			{% else %}
		<div id="feedback"><p class="message">{% trans "[MESSAGE] You have to wait that your teacher creates a folder." %}</p></div>
			{% endif %}
		{% endif %}
	</div>
		
{%endblock%}

{% block script%}
	<script type="text/javascript">
		function applyFilter()
			{
				$('#filter').submit();	
				return false;
			}
	</script>
{% endblock %}